﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 第二次作业
{
    public class Bank
    {
        private List<Account> accounts = new List<Account>();
        public Account this[string accountNumber]
        {
            get { return accounts.Find(a => a.id == accountNumber); }
        }
        public void AddAccount(Account account)
        {
            if (this[account.id] == null)
            {
                accounts.Add(account);
                Console.WriteLine($"账户 {account.id} 开户成功");
            }
            else
            {
                Console.WriteLine("账号已存在");
            }
        }
    }
}
